#include "rabbitvcs_action.h"

RabbitVcsAction::RabbitVcsAction(RabbitVcsType vcs, const char *name, QObject *parent)
    : QAction(parent), vcs(vcs), actionName(QString::fromUtf8(name))
{
    init();
}

RabbitVcsAction::RabbitVcsAction(RabbitVcsType vcs, const char *name, const char *title, const char *icon, QObject *parent)
    : QAction(parent), vcs(vcs), actionName(QString::fromUtf8(name))
{
    if (title)
        setText(QString::fromUtf8(title));
    if (icon)
        setIcon(QIcon::fromTheme(QString::fromUtf8(icon)));
    init();
}

RabbitVcsAction::~RabbitVcsAction()
{}

void RabbitVcsAction::init()
{
    connect(this, &QAction::triggered, [this](bool checked) {
        Q_UNUSED(checked);
        Q_EMIT actionTriggered(vcs, actionName);
    });
}
